﻿using FreesenseSubAIS.Core;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Telerik.WinControls.UI;

namespace FreesenseSubAIS.UI
{
    public partial class UserForm : RadForm
    {

       
        public UserForm()
        {
            InitializeComponent();
         
            //加载设备信息
            //MainForm.InputPanleID = "";
            //MainForm.isInputId = false;
            txtUserID.Text = Device.Parameter.CurentOperator;
        }

      
        private void saveRBtn_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtUserID.Text.Trim()))
            {
                if (txtUserID.Text.Trim() != Device.Parameter.CurentOperator)
                {
                    Device.Parameter.CurentOperator = txtUserID.Text.Trim();
                    Device.Parameter.BatchCode = Batch_tx.Text;
                    Device.SaveParameter();
                }
                this.DialogResult = DialogResult.OK;
            }
            else
            {
                MessageBox.Show("作业员代号不能为空！","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
            }
        }

        void UserForm_Shown(object sender, System.EventArgs e)
        {
            Batch_tx.Focus();
        }

        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            switch (keyData)
            {


                case Keys.Enter :
                    saveRBtn.PerformClick();
                    break;


            }
            return base.ProcessCmdKey(ref msg, keyData);
        }

        private void UserForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (this.DialogResult != DialogResult.OK)
            {
                //if (!string.IsNullOrEmpty(MainForm.InputPanleID))
                //{
                //    MainForm.isInputId = true;
                //}
            }
        }

     
    }
}
